import java.util.Stack;

/**
 * @BelongsProject : LeetCode
 * @Author : WXY
 * @CreateTime : 2022-12-07  09:58
 * @Description : 剑指 Offer 09. 用两个栈实现队列
 * @Version : 1.0
 */

public class Num09_CQueue {
    class CQueue {

        public Stack<Integer> stackPush;
        public Stack<Integer> stackPop;

        public CQueue() {
            stackPush = new Stack<Integer>();
            stackPop = new Stack<Integer>();
        }

        public void appendTail(int value) {
            stackPush.push(value);
            pushToPop();

        }

        public int deleteHead() {
            if (stackPop.empty() && stackPush.empty()) {
                return -1;
            }
            pushToPop();
            return stackPop.pop();

        }

        public void pushToPop() {
            if (stackPop.isEmpty()) {
                while (!stackPush.empty()) {
                    stackPop.push(stackPush.pop());
                }
            }
        }

    }
}
